package com.nbk.composition

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
import com.baomidou.mybatisplus.core.toolkit.support.SFunction
import com.baomidou.mybatisplus.extension.kotlin.KtQueryWrapper
import com.nbk.composition.dao.bean.*
import com.nbk.composition.dao.repository.*
import com.nbk.composition.manager.TeacherAllot
import com.nbk.composition.utils.getCurrentTime
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.CommandLineRunner
import org.springframework.stereotype.Component

/**
 * Author:  LuoHaoLun
 * Email :  506503279@qq.com
 * Date  :  2021/5/24
 */
@Component
class SpringTest : CommandLineRunner {

    @Autowired
    private lateinit var teacherMapper: TeacherMapper

    @Autowired
    private lateinit var studentMapper: StudentMapper

    @Autowired
    private lateinit var compositionMapper: CompositionMapper

    @Autowired
    private lateinit var modelCompositionMapper: ModelCompositionMapper

    @Autowired
    private lateinit var orderMapper: OrderMapper


    override fun run(vararg args: String?) {

//        val queryTeacher = KtQueryWrapper(Teacher::class.java).apply { select(Teacher::id) }
//        val teacherIds: List<Int> = teacherMapper.selectObjs(queryTeacher) as List<Int>
//        val teacherMap = teacherIds.map { id ->
//            val queryComposition = KtQueryWrapper(Composition::class.java).apply {
//                eq(Composition::teacherId, id)
//                eq(Composition::state, "待支付")
//            }
//            id to compositionMapper.selectCount(queryComposition)
//        }.toMap()
//        TeacherAllot.initTeacherMap(teacherMap)


//        val queryWrapper = KtQueryWrapper(Student::class.java)
//        queryWrapper.eq(Student::device, "13").last("limit 1")
//        val student = studentMapper.selectOne(queryWrapper)
//
//        println("是否为空：" + (student == null))


//        modelCompositionMapper.insert(ModelComposition())

//        orderMapper.insert(Order())
//        teacherMapper.insert(Teacher().apply { name = "周老师" })
//        teacherMapper.insert(Teacher().apply { name = "张老师" })
//        teacherMapper.insert(Teacher().apply { name = "王老师" })
//        teacherMapper.insert(Teacher().apply { name = "李老师" })
//        compositionMapper.insert(Composition().apply {
//            correct.add(Action(seq = 55))
//
//
//        })
    }
}